public class Animal {
    String type;
    int age;
public Animal(String type,int age){

    this.type=type;
    this.age=age;

}

    public void eat(){
        System.out.println("吃食物");
    }

    public void speak(){
        System.out.println("发出叫声");
    }

}


class Dog extends Animal{
    String name;

    public Dog(String type, int age, String name) {
        super(type, age);
        this.name = name;
    }

    public static void main(String[] args) {

        Dog dog=new Dog("狗",2,"旺财");
        System.out.println("他是一只"+dog.type+" 它的名字为:"+dog.name);
        dog.speak();
        dog.eat();

    }

}